package com.example.practice2023.controller;

import com.example.practice2023.pojo.Rotation;
import com.example.practice2023.service.RotationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/rotation")
public class RotationController {

    @Autowired
    private RotationService rotationService;

    @GetMapping("/get")
    public List<Rotation> getRotations() {
        return rotationService.getRotations();
    }

    @GetMapping("/get/{id}")
    public Rotation getRotationById(@PathVariable int id) {
        return rotationService.getRotationById(id);
    }

    @PostMapping("/add")
    public void addRotation(@RequestBody Rotation rotation) {
        rotationService.addRotation(rotation);
    }

    @PutMapping("/update")
    public void updateRotation(@RequestBody Rotation rotation) {
        rotationService.updateRotation(rotation);
    }

    @DeleteMapping("/delete/{id}")
    public void deleteRotation(@PathVariable int id) {
        rotationService.deleteRotation(id);
    }

    @DeleteMapping("/deleteMultiple")
    public void deleteMultipleRotations(@RequestBody List<Integer> ids) {
        rotationService.deleteMultipleRotations(ids);
    }


}
